<?php
include_once('admin_global.php');
bn_include_lib('bn_jquery');
$gad=new bn_gadget();
$theme->add_block('body');
$theme->add_script(jquery_element(':submit[id="state[]"]','click','
var val=$(this).closest("tr").find("td:first").html();
var pos=$(this).closest("tr").find("#gpos").val();
$.post(window.location.href,{cmd:$(this).val(),dir:val,pos:pos},function(data){$("#show").html(data)});'));

$grid=new bn_grid();
$grid->header->enable=true;
$grid->delete->caption=$lang[17];
$grid->delete->enable=true;
$grid->delete->cssclass='button red';

$cdir=new column;
$cdir->caption=$lang[55];
$cdir->field_name='dir';
$grid->columns->append($cdir);

$fdir=new column;
$fdir->caption=$lang[56];
$fdir->field_name='filename';
$grid->columns->append($fdir);

$ndir=new column;
$ndir->caption=$lang[57];
$ndir->field_name='name';
$grid->columns->append($ndir);

$pdir=new column;
$pdir->caption=$lang[58];
$pdir->field_name='position';
$pdir->function='bn_gadget::ddl_postion';
$grid->columns->append($pdir);

$pdir=new column;
$pdir->caption=$lang[59];
$pdir->template='<input type="submit" name="state[]" id="state[]" value="<%status%>" class="button"/>';
$grid->columns->append($pdir);

$cmd=$_POST['cmd'];
if(isset($cmd))
{
    if($cmd=='disable')
       $gad->install_gadget($_POST['dir'],$_POST['pos']);
    if($cmd=='enable')
       $gad->unistall($_POST['dir']);
    if($cmd=='delete')
    $gad->delete($_POST['id']);
    die($grid->show($gad->gadget_list()));
}
?>
<label><?php echo $lang[60] ?></label>
<input type="file" size="35" name="gfile" id="gfile" class="input-text"/>
<input type="submit" name="submit" id="submit" value="<?php echo $lang[15] ?>" class="button"/>
<div id="show">
<?php
$grid->show($gad->gadget_list());
?>
</div>
<?php
$theme->render();
?>